package com.guidinggame.activities;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.example.guidinggame.R;
import com.guidinggame.adapter.MoreListAdapter;
import com.guidinggame.db.DBHelper;

import android.support.v4.app.*;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;

public class MoreListActivity extends Activity {

	private List<Map<String, Object>> mData;
	private ListView moreList;
	

	public MoreListActivity() {

	}

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_more);
		moreList=(ListView)findViewById(R.id.lv_more);
		
		//初始化数据
		initData();
		
		//初始化界面
		initView();
		
	}
	
	
	
	private void initData() {

		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("title", "G1");
		map.put("info", "google 1");
		map.put("img", R.drawable.ic_launcher);
		list.add(map);
		
		map = new HashMap<String, Object>();
		map.put("title", "G2");
		map.put("info", "google 2");
		map.put("img", R.drawable.ic_launcher);
		list.add(map);

		map = new HashMap<String, Object>();
		map.put("title", "G3");
		map.put("info", "google 3");
		map.put("img", R.drawable.ic_launcher);
		list.add(map);
		mData=list;
	}

	private void initView(){
		MoreListAdapter adapter = new MoreListAdapter(this, mData);
		TextView tv=new TextView(this);
		tv.setText("Google Phone");
		
		//添加ListView头项
		moreList.addHeaderView(tv);
		
		//设置监听方法
		moreList.setOnItemClickListener(moreLstItemLstner);
		
		//注：适配器设置在显示最后写
		moreList.setAdapter(adapter);
		
	}
	
	private OnItemClickListener moreLstItemLstner=new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View itemView, int position,
				long arg3) {
			Toast.makeText(getApplication(), position+":",
					Toast.LENGTH_SHORT).show();
		}
	
	};
	

}
